<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class TB_User extends CI_Model {
function __construct()
    {
        parent::__construct();
        $this->load->database();
    }
    	
	function Insert($UserEnt)
	{
			$this->db->insert('TB_User', $UserEnt); 
	}
	function Update($UserEnt)
	{
			$this->db->update('TB_User', $UserEnt,array('UserID' => $UserEnt['UserID']));
	}
	function Delete($UserID)
	{
			$this->db->delete('TB_User', array('UserID' => $UserID)); 
	}
	function GetAllUser()
	{
	//	$this->db->orderby('frequency desc, sitename asc'); 
		$query=$this->db->get('TB_User');
			return $query->result();
		
	}
	function GetUserByID($UserID)
	{
		$this->db->where('UserID', $UserID);
		$query=$this->db->get('TB_User');
			return $query->result();
	}
	function UserIsExist($UserName,$Password)
	{
		
		$sql = "select * from TB_User where UserName=? and Password=?"; 
		$query =$this->db->query($sql, array($UserName,$Password)); 
		//$this->db->where('UserName', $UserName);
		//$this->db->where('Password', $Password);
	//	$query=$this->db->query("select * from TB_User where UserName=".$UserName." and Password=".$Password);
		if ($query->num_rows() > 0)
			return true;
		else
			return false;
	}
}
?>